package com.huaxin.hxmodulesystem.controller;

import com.huaxin.hxmodulesystem.dto.ResponseResult;
import com.huaxin.hxmodulesystem.service.SmSService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "短信接口")
@RestController
@RequiredArgsConstructor
@RequestMapping("/v1/sys/sms")
public class SMSController {

    private final SmSService utilsService;

    //发送短信验证码
    @Operation(summary = "发送短信验证码", description = "发送短信验证码")
    @GetMapping("/sendSmsVerificationCode")
    public ResponseResult<String> sendSmsVerificationCode(@Parameter(description = "手机号", required = true, name = "phoneNumber") @RequestParam(value = "phoneNumber") String phoneNumber) {
        return utilsService.sendSmsVerificationCode(phoneNumber);
    }

    @Operation(summary = "验证短信验证码", description = "验证短信验证码")
    @GetMapping("/verifySmsVerificationCode")
    public ResponseResult<String> verifySmsVerificationCode(@Parameter(description = "手机号", required = true, name = "phoneNumber") @RequestParam(name = "phoneNumber") String phoneNumber,
                                                            @Parameter(description = "验证码", required = true, name = "verificationCode") @RequestParam(name = "verificationCode") String verificationCode) {
        return utilsService.verifySmsVerificationCode(phoneNumber, verificationCode);
    }
}
